<template>
  <a-card :bordered="false" class="card-area">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <!-- 搜索区域 -->
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="名称" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
              <a-input placeholder="请输入名称查询" v-model="queryParam.roleName"></a-input>
            </a-form-item>
          </a-col>
          <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
            <a-col :md="6" :sm="24">
              <a-button type="primary" @click="searchQuery">查询</a-button>
              <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
            </a-col>
          </span>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator"  style="margin-top: 5px">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleModeler(record)">设计</a>
          <a-divider type="vertical" />

          <a-dropdown>
            <a class="ant-dropdown-link">
              更多 <a-icon type="down" />
            </a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleForm(record.id)">表单</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>


      </a-table>
    </div>
    <!-- table区域-end -->
    <AddForm ref="modalForm"></AddForm>
    <Modeler ref="modeler"></Modeler>
    <DesignForm ref="designForm"></DesignForm>
  </a-card>
</template>

<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import AddForm from './modules/AddForm'
  import Modeler from './modules/Modeler'
  import DesignForm from './modules/DesignForm'
  export default {
    name: "FlowList",
    mixins:[JeecgListMixin],
    components: {
      AddForm,
      Modeler,
      DesignForm
    },
    data () {
      return {
        
        description: '流程管理页面',
        // 查询条件
        queryParam: {},
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title: '流程名称',
            align:"center",
            dataIndex: 'name'
          },
          {
            title: '发布',
            align:"center",
            dataIndex: 'deploymentId',
            customRender:function (t,r,index) {
              return r.deploymentId?'已发布':'未发布';
            }
          },
          {
            title: '状态',
            align:"center",
            dataIndex: 'processSuspended',
            customRender:function (t,r,index) {
              return r.processSuspended?'挂起':'激活';
            }
          },
          {
            title: '版本',
            dataIndex: 'version',
            align:"center"
          },
          {
            title: '创建时间',
            dataIndex: 'createTime',
            align:"center",
            sorter: true
          },
          {
            title: '更新时间',
            dataIndex: 'updateTime',
            align:"center",
            sorter: true
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/workflow/process/list",
          delete: "/workflow/delete",
        },
      }
    },
    computed: {
      
    },
    methods: {
      handleModeler: function(record){
        this.$refs.modeler.visible = true;
        this.$refs.modeler.modelUrl = window._CONFIG['domianURL'] + '/modeler/editor?modelId=' + record.id;
        this.$refs.modeler.title = "流程设计";
      },
      handleForm: function(modelId){
        this.$refs.designForm.visible = true;
        this.$refs.designForm.title = "表单设计";
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>